<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- <script src="./index.js"></script> -->
    <!-- <script src="../dist/main.js"></script> -->
    <!-- <script src="../dist/budle.js"></script> -->
</head>

<body>
    <ul>
        <li>这是第0个li</li>
        <li>这是第1个li</li>
        <li>这是第2个li</li>
        <li>这是第3个li</li>
        <li>这是第4个li</li>
        <li>这是第5个li</li>
        <li>这是第6个li</li>
        <li>这是第7个li</li>
        <li>这是第8个li</li>
        <li>这是第9个li</li>
        <li>测试</li>
        <li>更新</li>
        <li>我是一个小太阳</li>
        <li>我修改了xxxx</li>
        <li>zs提交了xxxx</li>
        <li>新建test</li>
        <li>苏帅提交了xxx</li>
        <li>新建new,并更新</li>
        <li>测试gitUI</li>
        <li>测试gitUI远程仓库修改</li>
        <li>测试gitUI远程仓库修改111</li>
        <li>测试git插件222</li>
        <li>测试修改xxxxx</li>
    </ul>
    <script>
        /* //手写reduce
        const arr = [1, 2, 3, 4];
        Array.prototype.myReduce = function (fn, initval) {
            let result = initval;
            console.log(this, '我');
            for (let i = 0; i < this.length; i++) {
                result = fn(result, this[i]);
            }
            return result;
        }
        console.log(arr.myReduce((l, r) => l + r, 2)); // 12 */

        //手写map,filter
        function map(arr, fn) {
            let newArr = [];

            for (let i = 0; i < arr.length; i++) {
                newArr[i] = fn(arr[i], i, arr)
            }

            return newArr;
        }

        function filter(arr, fn) {
            let newArr = [];

            for (let i = 0; i < arr.length; i++) {
                if (fn(arr[i], i, arr)) {
                    newArr.push(arr[i]);
                }
            }

            return newArr;
        }
        var arr = [1, 2, 3, 4, 5, 6]
        console.log(map(arr, (item) => item + 1))
        console.log(filter(arr, (item) => item > 3))
    </script>
</body>